package gui.toolbox;

import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;

import model.listener.CoordinateListener;

public class CoordinateSelector extends JPanel implements ChangeListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1818099714107081098L;

	private EventListenerList listeners = new EventListenerList();

	private JCheckBox x = new JCheckBox("x");
	private JCheckBox y = new JCheckBox("y");;
	private JCheckBox z = new JCheckBox("z");;

	public CoordinateSelector() {
		this.add(x);
		this.add(y);
		this.add(z);

		x.addChangeListener(this);
		y.addChangeListener(this);
		z.addChangeListener(this);

	}

	@Override
	public void stateChanged(ChangeEvent e) {
		for (CoordinateListener l : listeners
				.getListeners(CoordinateListener.class)) {
			l.setDisplayX(x.isSelected());
			l.setDisplayY(y.isSelected());
			l.setDisplayZ(z.isSelected());
		}
	}

	public void addCoordinateListener(CoordinateListener l) {
		listenerList.add(CoordinateListener.class, l);
	}

	public void removeCoordinateListener(CoordinateListener l) {
		listenerList.remove(CoordinateListener.class, l);
	}
}
